<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"></c:set>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>55社区</title>
    <meta name="description" content="">
    <meta name="keywords" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link href="${ctx}/static/css/amazeui.min.css" rel="stylesheet" type="text/css" />
    <link href="${ctx}/static/css/style.css" rel="stylesheet" type="text/css" />
    <script src="${ctx}/static/js/jquery-1.10.2.min.js"></script>
    <script src="${ctx}/static/js/time.js"></script>
<jsp:include page="common.jsp"></jsp:include>
</head>
<body>
<header data-am-widget="header" class="am-header am-header-default sq-head ">
    <div class="am-header-left am-header-nav">
        <a href="javascript:history.back()" class="">
            <i class="am-icon-chevron-left"></i>
        </a>
    </div>
    <h1 class="am-header-title">
        <a href="" class="">登录</a>
    </h1>
</header>
<div style="height: 49px;"></div>
<div class="login-logo">
    <img src="${ctx}/static/images/logo.png" />
</div>
<form action="#" method="post" id="loginForm" onsubmit="return false;">
<input type="text" name="name" id="mobile" placeholder="请输入用户名/手机号" class="login-name">
<input type="password" name="password" id="password" placeholder="请输入密码" class="login-password">
<input type="button" class="login-btn" src="${ctx}/mobile/member.jsp" value="我要登录">
<input type="button" class="reg-btn" value="我要注册">
</form>
<div class="agree">
    <a href="forgetpassword.html" class="forget">忘记密码？</a>
</div>
<script>
    //给登录按钮绑定事件
    $(".login-btn").click(function () {
        //表单序列化     将表单中所有数据按照name属性为key，value作为值打包json格式
        <%--var myData=$("#loginForm").serialize();--%>
        <%--var name=$("#mobile").val();--%>
        <%--var pas=$("#password").val();--%>
        <%--location.href="${ctx}/user/login.do?name="+name+"&pas="+pas;--%>
        var myData=$("#loginForm").serialize();
      console.info("myData"+myData);
       $.get("${ctx}/user/login.do",myData,function (data) {
            //登录成功进入后台，不成功提示重新登录，重载页面
            if(data.state==0){//登录成功
                window.location.href="${ctx}/mobile/index.jsp";
            }else {
                alert(data.msg);//提示错误信息
            }

        },'json');

    });

</script>
</body>
</html>
